<?php
    define('WP_USE_THEMES', false); 
    
    require('./wp-blog-header.php');
    require('./DBHandler.php');

    $dbHandler = new DBHandler;

    $courseId = '';
    $assignmentId = '';

    if ($_GET)
    {
        $authorId = 6; // get_current_user_id();
        $courseId = $_GET['courseid'];
        $assignmentId = $_GET['assignmentid'];

        $assignmentPost = $dbHandler->GetAssignment($assignmentId);

        $paths = $dbHandler->GetAssignmentFilePaths($authorId, $courseId, $assignmentId);
    }
?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title></title>
    </head>
    <body>
        <h2><?php echo $assignmentPost->post_title; ?></h2>
        <p><?php echo $assignmentPost->post_content; ?></p>
        <br/>
        <?php
            if ($paths)            
            {
                echo "<img src='" . $paths[0] . "' height=100 width=150><br/>";
                echo "<object type='application/x-java-applet' height='300' width='550'>";
                echo "<param name='code' value='Sample' />"; // TODO: Need to standardize class name in assignment submission
                echo "<param name='archive' value='" . $paths[1] . "' />";
                echo "Applet failed to run.  No Java plug-in was found.";
                echo "</object>";
            }
        ?>
    </body>
</html>
